<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>扫码支付</title>
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta http-equiv="Cache-Control" content="no-transform">
		<meta name="format-detection" content="telephone=no">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
		<link rel="stylesheet" href="style/css/basic.css" />	
		<link rel="stylesheet" href="style/css/pay.css" />
		<script type="text/javascript" src="style/plugin/mui/js/mui.min.js"></script>
		<script type="text/javascript" src="style/js/jquery-1.8.3.min.js"></script>
		<script type="text/javascript" src="style/mockjs/dist/mock.js"></script>
		<script type="text/javascript" src="style/js/vue.min.js"></script>
		<script type="text/javascript" src="style/js/vue-resource.js"></script>
		<script type="text/javascript" src="style/js/md5.js"></script>
		<script type="text/javascript" src="style/js/basic.js"></script>
		<style type="text/css">
			.ensure{
				width:90%;
				height:50px;
				background:#C2BE9E;
				text-align:center;
				line-height: 50px;
				color:#FFF9EC;
				border-radius: 5px;
				font-size:16px;
				margin:0 auto;
			}
			.ensure:hover{
				box-shadow: 2px 2px;
			}
		</style>
	</head>
	<body>
	    <div id="header"> 
			<h1>扫码支付</h1>
			<span class="backicon"></span>
		</div>
		<div id="account">
			<div class="body">
				<div class="pay">
					<div class="totalprice">
						<p>付款金额</p>
						<p>￥{{allpri.toFixed(2)}}</p>
						<i class="left"></i>
						<i class="right"></i>
					</div> 
					<div class="code">
						<img :src="actMsg+'&t='+ticket+'&sign='+sign" alt="code" v-if="actMsg!=''"/>
					</div>
				</div>
			<div class="ensure" @tap="ensureOrder">确认完成</div>
			</div>	
		</div>
		
		<script>
//			that.recv=plus.webview.currentWebview().goodsId
            new Vue({
            	el:"#account",
            	data:{
            		actMsg:"",
            		allpri:"",
            		ticket:"",
				    sign:"",
				    recv:""
            	},
            	methods:{
            		ensureOrder:function(){
            			this.$http.post(domain+"/good/getPayStatus?t="+this.ticket+"&sign="+this.sign,{
				        	order_no:this.recv
				        },{emulateJSON:true}).then(//获取新闻列表
				            function (res) {
				                // 处理成功的结果
				                console.log(res.body)	
				                if(res.body.data==1){
				                	mui.toast("该订单已支付成功") 
   				                    openurl("agent_index")
				                }else{
				                	mui.toast("支付失败")
				                }
				            },function (res) {
				            // 处理失败的结果
				            console.log(res)   
				            }
				        );
            		}
            	},
            	created:function(){
            		var that=this
            		that.ticket=localStorage.getItem("tick")
                    that.sign=localStorage.getItem("sig")
            		mui.plusReady(function(){
            			that.recv=plus.webview.currentWebview().current
            			that.allpri=plus.webview.currentWebview().totalPri
            			that.$http.post(domain+"/good/createPayQrCode?t="+that.ticket+"&sign="+that.sign,{
				        	order_no:that.recv
				        },{emulateJSON:true}).then(//获取新闻列表
				            function (res) {
				                // 处理成功的结果
				                console.log(res.body)	
				                if(res.body.code==1){
				                  that.actMsg=rcode+res.body.data;
				                  console.log(that.actMsg.data)
				                } 
				            },function (res) {
				            // 处理失败的结果
				            console.log(res)   
				            }
				        );
            		})
            		
            	}
            })
		</script>
	</body>
</html>
